﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SBlogCore.Common.App.Manager
{
    public class AppSetting
    {
        private static ConfigurationManager? configurationManager = default;
        private static object AppsettingsLock = new object();
        public static string ReadAppSettings(string key)
        {
            if (configurationManager == default)
            {
                lock (AppsettingsLock)
                {
                    if (configurationManager == default)
                    {
                        configurationManager = new ConfigurationManager();
                        //reloadOnChange:true 发生变化的时候重新加载
                        configurationManager.AddJsonFile("appsettings.json", true, reloadOnChange: true);
                    }
                }
            }
            return configurationManager[key];
        }
    }
}
